﻿using System;

namespace Less.Util
{
    [Serializable]
    public class SqlCommandException: ApplicationException
    {
        public string  Command { get; set; }
        public string MethodSource { get; set; }

        public SqlCommandException()
        {
            
        }
        public SqlCommandException(string command, string methodSource, Exception inner):base(command,inner)
        {
            Command = command;
            MethodSource = methodSource;
        }
        public override string Message
        {
            get {
                return this.Command ?? "";
            }
        }
    }
    [Serializable]
    public class RecordNotFoundException: ApplicationException
    {
        public string Key { get; set; }

        public RecordNotFoundException()
        {
            
        }
        public RecordNotFoundException(string key)
        {
            Key = key;
        }
        
        public override string Message
        {
            get
            {
                return Msg.NotFound(Key);
            }
        }
    }

    [Serializable]
    public class RecordAlreadyExistsException : ApplicationException
    {
        public string UniqueKey { get; set; }

        public RecordAlreadyExistsException()
        {

        }
        public RecordAlreadyExistsException(string uniqueKey)
        {
            UniqueKey = uniqueKey;
        }

        public override string Message
        {
            get
            {
                return Msg.AlreadyExists(UniqueKey);
            }
        }
    }
}
